//
//  ViewController.m
//  transform动画练习
//
//  Created by zxy on 2018/4/11.
//  Copyright © 2018年 foxconn. All rights reserved.
//

#import "ViewController.h"
#import "POP.h"
@interface ViewController ()

@property (weak, nonatomic) IBOutlet UIView *aniView;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    self.aniView.layer.cornerRadius = 50;
    
//    [self pop_showWithAlert:self.aniView];
    [self showWithAlert:self.aniView];
}


/**
 添加Alert入场动画
 @param alert 添加动画的View
 */
- (void)showWithAlert:(UIView*)alert{
    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
    animation.duration = 0.8;
    NSMutableArray *values = [NSMutableArray array];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)]];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.2, 1.2, 1.0)]];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.6, 0.6, 1.0)]];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];
    animation.values = values;
    [alert.layer addAnimation:animation forKey:nil];
}

-(void)pop_showWithAlert:(UIView *)alert{
    
    
    
    POPSpringAnimation *ani = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerScaleXY];
    ani.springSpeed = 0.f;
    ani.fromValue = [NSValue valueWithCGPoint:CGPointMake(0.5f, 0.5f)];
    ani.toValue = [NSValue valueWithCGPoint:CGPointMake(2.f, 2.f)];
    ani.autoreverses = YES;
    [alert.layer pop_addAnimation:ani forKey:nil];
    
}

@end
